﻿/*                              
   Copyright 2011 Nils Kopal, Christopher Krüger, Simone Sauer, Dennis Nolte, Uni Duisburg-Essen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace Sharebert.SearchLibrary.Interfaces
{
    /// <summary>
    /// Servers network interface used to serve clients. Can be started and stopped.
    /// Triggers events if a client sends a list with files to share 
    /// or searches files.
    /// </summary>
    public interface IIndexServer
    {
        /// <summary>
        /// Opens a network socket and waits for new connections.
        /// </summary>
        void Start();

        /// <summary>
        /// Stops listening and closes the socket.
        /// </summary>
        void Stop();

        /// <summary>
        /// IP address, that the server is listening on.
        /// </summary>
        IPAddress IP { get; }

        /// <summary>
        /// Port, that the server is listening on.
        /// </summary>
        int Port { get; }

        /// <summary>
        /// Sending and receiving messages will timeout after the specified time in seconds.
        /// </summary>
        int Timeout { get; set; }


        /// <summary>
        /// The maximum number of parallel connections. Must be a value between 1 and 100.
        /// </summary>
        uint AllowedClients { get; set; }

        /// <summary>
        /// A client send a file offer message.
        /// </summary>
        event EventHandler<OfferedFilesEventArgs> OfferReceived;

        /// <summary>
        /// A client send a search request.
        /// </summary>
        event EventHandler<SearchReceivedEventArgs> SearchReceived;
    }
}
